Load imagery and create raster brick
library(raster)
library(sp)
l.blue <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B2.TIF')
l.green <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B3.TIF')
l.red <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B4.TIF')
l.nir <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B5.TIF')
l.swir1 <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B6.TIF')
l.swir2 <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B7.TIF')
l.pc <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B8.TIF')
l.cirrus <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B9.TIF')
l.t1 <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B10.TIF')
l.t2 <- raster('LC08_L1TP_024030_20170602_20170615_01_T1/LC08_L1TP_024030_20170602_20170615_01_T1_B11.TIF')
# Create raster brick
ls = brick(l.red,l.green,l.blue,l.nir,l.swir1,l.swir2,l.cirrus,l.t1,l.t2)
# CROP
e <- extent(280000, 330000, 4750000, 4800000)
ls.c = crop(ls,e)
names(ls.c) <- c('red','green','blue','NIR','SWIR1','SWIR2','cirrus','thermal1','thermal2')
writeRaster(ls.c,filename = 'Madison_Landsat_20170602.tif', format="GTiff", overwrite=TRUE)
Load cropped imagery
library(raster)
## Loading required package: sp
library(sp)
r1 = brick('Madison_Landsat_20170602.tif')
r2 = brick('Madison_Landsat_20180317.tif')
names(r1) <- c('red','green','blue','NIR','SWIR1','SWIR2','cirrus','thermal1','thermal2')
names(r2) <- c('red','green','blue','NIR','SWIR1','SWIR2','cirrus','thermal1','thermal2')
r1
## class : RasterBrick
## dimensions : 1667, 1667, 2778889, 9 (nrow, ncol, ncell, nlayers)
## resolution : 30, 30 (x, y)
## extent : 280005, 330015, 4750005, 4800015 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=16 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
## data source : /Users/hilarydugan/Documents/Zoo955/Lecture9_Landsat/Madison_Landsat_20170602.tif
## names : red, green, blue, NIR, SWIR1, SWIR2, cirrus, thermal1, thermal2
## min values : 3868, 5598, 7421, 5232, 5142, 5058, 4995, 20368, 19692
## max values : 65535, 65535, 61486, 65535, 65535, 65535, 6626, 38316, 32482
Plot imagery
plot(r2)

Plot RGB
plotRGB(r1, r = 1, g = 2, b = 3, axes = TRUE, stretch = "lin",
main = "Landsat True Color Composite")

plotRGB(r2, r = 1, g = 2, b = 3, axes = TRUE, stretch = "lin",
main = "Landsat True Color Composite")
